package edu.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;

import edu.st.selenium.model.Film;

public class MoviePage extends InternalPage {
	
	@FindBy (css = "h2")
	private WebElement filmTitle;
	
	@FindBy (css = "img[title='Remove']")
	private WebElement removeLink;
	
	public MoviePage(PageManager pages) {
		super(pages);
	}
	
	public MoviePage ensurePageLoaded() {
		    super.ensurePageLoaded();
		    wait.until(presenceOfElementLocated(By.cssSelector("img[title='Remove']")));
		    return this;
		  }
	
	public String getFilmTitle(){
		return filmTitle.getText();
	}
	
	public InternalPage clickRemoveButton() {
		removeLink.click();
		wait.until(alertIsPresent()).accept();
		return pages.internalPage;		
	}
	
}
